package com.my.design.clone;

import java.util.Date;
import java.util.Objects;

public class TestClone {

    public static void main(String[] args) throws CloneNotSupportedException {
        Date d = new Date();
        Book1 book1 = new Book1("张三",d);
        Book1 clone = (Book1)book1.clone();

        Book2 book2 = new Book2("李四",d);
        Book2 clone2 = (Book2) book2.clone();
        d.setTime(d.getTime() + 86400 * 1000L);
        System.out.println("浅克隆原型对象："+ book1);
        System.out.println("浅克隆复制对象：" + clone);
        System.out.println("深克隆原型对象："+ book2);
        System.out.println("深克隆复制对象：" + clone2);
    }
}
